#include "InitWindow.h"

uint32_t mini_engine::InitWindow::WIDTH = 800;
uint32_t mini_engine::InitWindow::HEIGHT = 600;
mini_engine::InitWindow *mini_engine::InitWindow::m_initWindow = nullptr;
GLFWwindow *mini_engine::InitWindow::window = nullptr;

mini_engine::InitWindow::InitWindow()
{
}

void mini_engine::InitWindow::createWindow()
{
    cout << "create window" << endl;
    glfwInit();
    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
    glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
    window = glfwCreateWindow(WIDTH, HEIGHT, "TITLE", nullptr, nullptr);
    glfwSetMouseButtonCallback(window, mouse_callback);
    // glfwMaximizeWindow(window);
}

void mini_engine::InitWindow::mouse_callback(GLFWwindow *window, int button, int action, int mods)
{
    cout << "点击：" << button << endl;
    FrameBufferPick p;
    p.pick();
}

mini_engine::InitWindow *mini_engine::InitWindow::getInitWindow()
{
    if (m_initWindow == nullptr)
    {
        m_initWindow = new InitWindow();
        static InitWindowDestruction initWindowDestruction;
    }
    return m_initWindow;
}

mini_engine::InitWindow::~InitWindow()
{
}

mini_engine::InitWindow::InitWindowDestruction::~InitWindowDestruction()
{
    if (m_initWindow != nullptr)
    {
        delete m_initWindow;
        m_initWindow = nullptr;
    }
}